package com.psfd.demo.controller;

import com.psfd.demo.bean.User;
import com.psfd.demo.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class LoginController {

    @Resource
    private UserService userService;

    @RequestMapping("/login")
    public ModelAndView login(User user){
        System.out.println(user);
        ModelAndView view = new ModelAndView();
        List<User> userList = userService.list();
        for (User user1 : userList) {
            if (user1.getUserName().equals(user.getUserName()) && user1.getUserPassword().equals(user.getUserPassword())){
                view.setViewName("prj");
                return view;
            }
        }
        view.setViewName("index");
        return view;
    }
}
